home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6632 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.0 KB

  1. Path: goanna.cs.rmit.EDU.AU!not-for-mail
  2. From: ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2
  4. Subject: Re: Hungarian notation - whoops!
  5. Date: 12 Feb 1996 19:02:10 +1100
  6. Organization: Comp Sci, RMIT, Melbourne, Australia
  7. Message-ID: <4fms62$c0p@goanna.cs.rmit.EDU.AU>
  8. References: <30C40F77.53B5@swsbbs.com> <Pine.HPP.3.91.960124153551.24374C-100000@zeezrom.cs.byu.edu> <4e7ifl$et3@goanna.cs.rmit.EDU.AU> <Pine.HPP.3.91.960129133429.8419C-100000@foggy.cs.byu.edu> <4em29qINN39r@keats.ugrad.cs.ubc.ca> <Pine.HPP.3.91.960201015336.17360C-100000@clear.cs.byu.edu> <4f41vf$g8j@goanna.cs.rmit.EDU.AU> <Pine.HPP.3.91.960205124102.18647E-100000@warm.cs.byu.edu> <4fc157$jsf@goanna.cs.rmit.EDU.AU> <dewar.823793746@schonberg>
  9. NNTP-Posting-Host: goanna.cs.rmit.edu.au
  10. NNTP-Posting-User: ok
  11. X-Newsreader: NN version 6.5.0 #0 (NOV)
  12.  
  13. dewar@cs.nyu.edu (Robert Dewar) writes:
  14. >As far as I know, no current machine uses sign and magnitude representation
  15. >for integer values, so I obviously have a gap in my knowledge.
  16.  
  17. The machine in question was the B6700.  There have been changes, but the
  18. architecture is still in current production (I think they're called "A series"
  19. these days; check in comp.arch).
  20.  
  21. >S&M representation is so hostile at a design level, that I thought everyone
  22. >had abandoned it long ago.
  23.  
  24. >By the way, S&M is of course the right representation of floating-point,
  25. >using 2's complement for floating-point is a goof that only a designer
  26. >not understanding fpt would make!
  27.  
  28. The B6700 integer format was a special case of the floating point format.
  29. The arithmetic instructions delivered exponent-zero results if they were
  30. given exponent-zero inputs and the result _could_ be so represented.
  31.  
  32. I have done a paper design for a machine, but never a real machine.
  33. Sign and magnitude makes multiplication and division easy (just XOR the
  34. signs and operate on the absolute values).  Comparison isn't any harder
  35. than 2s magnitude.  If you can do addition and subtraction with 2s
  36. complement, you can certainly do it for sign and magnitude with only a
  37. couple more gate delays.  I don't know whether that cost can be reduced,
  38. but it's certainly not obvious that it _can't_.  Floating point is far
  39. more "hostile", but that doesn't stop people implementing it.
  40.  
  41. >The comment about 2's complement being silly is a bit like saying you
  42. >think that the use of binary is silly. The choice of 2's complement,
  43. >like binary, is made for architectural reasons, not to be convenient
  44. >for humans.
  45.  
  46. The underlying base is not something I usually have to think about.
  47. Most of my C code would work just as well in base 2, 3, 10, or even
  48. balanced ternary.  But the fact that abs(x) may deliver a negative
  49. number is something I have to live with the whole time.  _That_ is
  50. what I regard as silly.  I don't particularly care for the fact that
  51. there are representable numbers X, Y for which X % Y may overflow,
  52. either.  As far as I can see, the major "architectural
  53. reason" these days is "compatibility with existing C".  (A little
  54. unfair, but not a lot unfair.)  I remember the howls of dismay when
  55. RISC designers left out unaligned access; people don't put in unaligned
  56. access because they think it's a good thing, but for the "architectural
  57. reason" of selling into a market with lots of poor C code that people
  58. aren't (perhaps quite rationally) interested in fixing.  
  59.  
  60. I note that integer addition, subtraction, and comparison are single-
  61. cycle operations in many modern CPUs, and speculate that supporting
  62. sign and magnitude might not make any visible difference to performance.
  63. Things like pipelining, super-scalar, and caching probably make much
  64. more difference.
  65.  
  66. I think that Dijkstra was right when he said "the purpose of machines is
  67. to execute our programs", and I call anything "silly" that forces me to
  68. work around arithmetic nasties in my source code.
  69.  
  70. -- 
  71. "conventional orthography is ... a near optimal system for the
  72.  lexical representation of English words." Chomsky & Halle, S.P.E.
  73. Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
  74.